#include "MyClass.h"

Custom_Class::Custom_Class()
{
	CONSOLEVALUE("执行无参构造函数!");
	this->data = new char[100];
	this->data = "无参构造函数";
	std::cout << "" << &data << std::endl;
	CONSOLEKEY("data 的内存地址是",&this->data);
}

Custom_Class::Custom_Class(const char* input)
{
	std::cout << "执行有参构造函数!" << std::endl;
	this->data = new char[100];
	std::cout << "data 的内存地址是 : " << &data << std::endl;
}

Custom_Class::Custom_Class(const Custom_Class& other)
{
	std::cout << "other.data 的内存地址为 : " << &data << std::endl;
	std::cout << "this.data 的内存地址为 : " << &this->data << std::endl;
	this->data = other.data;
}


Custom_Class::Custom_Class(const Custom_Class& DeepOther, bool Sign)
{
	this->data = new char[100];
	if (Sign)
	{
		data = new char[strlen(DeepOther.data) + 1];
		strcpy_s(data, strlen(DeepOther.data) + 1, DeepOther.data);
	}
	else
	{
		this->data = DeepOther.data;
	}
}

// 移动构造函数
Custom_Class::Custom_Class(Custom_Class&& other)
{
	data = other.data;  // 移动指针
	other.data = nullptr;  // 将源对象指针置为 nullptr，避免释放原有资源
}


Custom_Class::~Custom_Class()
{
	delete[] this->data;
	std::cout << "我是析构函数" << std::endl;
}

Custom_Class Custom_Class::operator+(const Custom_Class& other) const
{
	return Custom_Class();
}

Custom_Class Custom_Class::operator-(const Custom_Class& other) const
{
	return Custom_Class();
}

Custom_Class Custom_Class::operator*(const Custom_Class& other) const
{
	return Custom_Class();
}

Custom_Class Custom_Class::operator%(const Custom_Class& other) const
{
	return Custom_Class();
}









void Friend_Function(Custom_Class &obj)
{
	CONSOLEKEY("obj.data",obj.data);
	CONSOLEKEY("obj.protect_value",obj.protect_value);
	CONSOLEKEY("obj.pri_value",obj.pri_value);
}


Friend_Class::Friend_Class()
{
	Custom_Class c;
	CONSOLEVALUE("我是Friend_Class类构造函数");
	CONSOLEKEY("c.data",c.data);
	CONSOLEKEY("c.protect_value",c.protect_value);
	CONSOLEKEY("c.pri_value",c.pri_value);


}

Friend_Class::~Friend_Class()
{

}